<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <!-- 用于移动端的视图缩放 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客后台分类页面</title>
    <link th:include="admin/commons_admin::head">
</head>
<body>

<!-- 导航栏 -->
<!-- m-padded-tb-min my-padding-topAndBottom-min -->
<nav th:replace="admin/commons_admin::menu(2)" class="ui inverted attached segment m-padded-tb-min m-shadow-small">
    <div class="ui container">
        <div class="ui inverted secondary stackable menu">
            <h2 class="ui teal header item">管理后台</h2>
            <a class="m-item item m-mobile-hide" href="blog.html"><i class="home icon"></i>博客</a>
            <a class="m-item item m-mobile-hide" href="types.html"><i class="idea icon"></i>分类</a>
            <a class="m-item item m-mobile-hide" href="tags.html"><i class="tags icon"></i>标签</a>
            <div class="right m-mobile-hide m-item menu">
                <div class="ui dropdown item">
                    <div class="text">
                        <img src="http://cdn.cczjblog.top/cczjBlog-img/avatar_min_cczj.jpg" alt="管理员头像" class="ui avatar image">
                        cczj
                    </div>
                    <i class="icon dropdown"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 这里的menu 和 toggle 没有具体效果 只是为了用class来获取元素 -->
    <a href="#" class="ui button menu toggle icon black m-right-top m-mobile-show">
        <i class="icon sidebar"></i>
    </a>
</nav>
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">
            <a href="#" th:href="@{/admin/types/input}" class="teal item">新增</a>
            <a href="#" th:href="@{/admin/types}" class="teal active item">列表</a>
        </div>
    </div>
</div>
<!-- 中间内容 -->
<div class="m-padded-tb-big m-container-small">
    <div class="ui container">
        <div class="ui message success" th:unless="${#strings.isEmpty(msg)}">
            <i class="close icon"></i>
            <div class="header">提示:</div>
            <p th:text="${msg}">管理员操作成功~</p>
        </div>
        <table class="ui teal table">
            <thead>
            <tr>
                <th>序号</th>
                <th>名称</th>
                <th>操作</th>
            </tr>
            </thead>
            <tr th:each="type,index:${page.content}">
                <td>[[${index.count}]]</td>
                <td th:text="${type.name}"></td>
                <td>
                    <a href="#" th:href="@{/admin/types/{id}/input(id=${type.id})}" class="ui mini button basic green">编辑</a>
                    <a href="#" th:href="@{/admin/types/{id}/delete(id=${type.id})}"
                       class="ui mini button basic red">删除</a>
                </td>
            </tr>
            <tfoot>
            <tr>
                <th colspan="6" class="mini vertical">
                    <div class="ui left floated pagination menu" th:if="${page.totalPages} > 1">
                        <a href="#" th:unless="${page.first}" th:href="@{/admin/types(page = ${page.number} - 1)}"
                           class="item">上一页</a>
                        <a href="#" th:unless="${page.last}"
                           th:href="@{/admin/types(page = ${page.number} + 1)}" class="item">下一页</a>
                    </div>
                    <a href="#" th:href="@{/admin/types/input}"
                       class="ui right floated teal mini basic button">新增</a>
                </th>
            </tr>
            </tfoot>
        </table>
    </div>
</div>

<!-- script -->
<!--/*/<th:block th:replace="admin/commons_admin::script">/*/-->
<!--/*/</th:block>/*/-->
<script>
    $('.ui.dropdown').dropdown({
        on: 'hover',
    });
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('m-mobile-hide');
    });
</script>
</body>
</html>